﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Core;

namespace DataAccess
{
 public   class TinTuc_Info
    {
        public int ID { get; set; }
        public string HinhDaiDien { get; set; }
        public string TieuDe { get; set; }
        public string TomTat { get; set; }
        public string NoiDung { get; set; }
        public DateTime NgayDang { get; set; }
        public bool TrangThai { get; set; }
     //lấy tất cả
        public static List<TinTuc_Info> TinTucs_ChonTatCa()
        {
            return CBO.FillCollection<TinTuc_Info>(DataProvider.Instance.ExecuteReader("sp_TinTucs_ChonTatCa"));
        }
        public static bool TinTuc_CapNhat(int ID, string HinhDaiDien, string TieuDe, string TomTat, string NoiDung, bool TrangThai)
        {
            try
            {
                object rs = DataProvider.Instance.ExecuteNonQuery("sp_TinTuc_CapNhat", ID, HinhDaiDien, TieuDe, TomTat, NoiDung, TrangThai);
                return true;
            }
            catch (Exception)
            {
                return false;
            }
        }
        public static bool TinTuc_Them(string HinhDaiDien, string TieuDe, string TomTat, string NoiDung, DateTime NgayDang, bool TrangThai)
        {
            try
            {
                object rs = DataProvider.Instance.ExecuteNonQuery("sp_TinTuc_Them", HinhDaiDien, TieuDe, TomTat, NoiDung, NgayDang, TrangThai);
                return true;
            }
            catch (Exception)
            {
                return false;
            }
        }
        public static bool TinTuc_Xoa(int ID)
        {
            try
            {
                int rs = DataProvider.Instance.ExecuteNonQuery("sp_TinTuc_Xoa", ID);
                return rs > 0;
            }
            catch (Exception)
            {
                return false;
            }
        }

        public static TinTuc_Info TinTuc_Chon(int ID)
        {
            return CBO.FillObject<TinTuc_Info>(DataProvider.Instance.ExecuteReader("sp_TinTuc_Chon", ID));
        }


        public static List<TinTuc_Info> TinTucs_Chon5TinDau()
        {
            return CBO.FillCollection<TinTuc_Info>(DataProvider.Instance.ExecuteReader("sp_TinTucs_ChonTatCa"));
        }

        
    }
}
